package com.cuit.dao.impl;

import com.cuit.dao.PrintDao;
import com.cuit.pojo.doctorPrint;
import org.apache.commons.dbutils.handlers.ArrayListHandler;

import java.util.List;

public class PrintDaoImpl extends BaseDao implements PrintDao {
    @Override
    public String QueryName(int d_id) {
        String sql="select d_name from doctors where d_id=?";
        return String.valueOf(queryForSingleValue(sql,d_id));
    }

    @Override
    public String QureyDepart(int d_id) {
        String sql="select d_department from doctors where d_id=?";
        return String.valueOf(queryForSingleValue(sql,d_id));
    }

    @Override
    public int[] QueryMaxOrder(int d_id) {
        int[] MaxOrder=new int[]{0, 0, 0, 0, 0, 0, 0, 0};
        int i=1;
        String sql="select max_order from d_order where d_week=? and d_id=?";
        for(;i<=7;i++){
            if((queryForSingleValue(sql,i,d_id))!=null&&!"".equals(String.valueOf(queryForSingleValue(sql,i,d_id)))) {
                MaxOrder[i-1] = Integer.valueOf(String.valueOf(queryForSingleValue(sql, i, d_id)));
            }
        }
        return MaxOrder;
    }

    @Override
    public int[] QueryOrderNum(int d_id) {
        int[] OrderNum=new int[]{0, 0, 0, 0, 0, 0, 0, 0};
        String sql="select order_num from order2 where day=? and d_id=?";
        for(int i=1;i<=7;i++){
            if((queryForSingleValue(sql,i,d_id))!=null&&!"".equals(String.valueOf(queryForSingleValue(sql,i,d_id)))) {
                OrderNum[i - 1] = Integer.valueOf(String.valueOf(queryForSingleValue(sql, i, d_id)));
            }
        }
        return OrderNum;
    }
}
